This tutorial focuses primarily on list boxes. Creating and maintaining a list box is pretty straight-forward, so a few “less obvious” things are demonstrated in this tutorial. In this tutorial, you will:
• create list boxes using different fonts
• create list boxes that are a _perfect_ height
• populate a list box with the names of the fonts on your Mac
• move lines between lists
• insert lines in alphabetic order
• delete lines from a list
We have also move the “response to an event” code out of the main event loop. You may want to do the same in your application when you notice that there is a fair amount of code dedicated to event processing.
In applications that have multiple windows, you may want to create a separate routine dedicated to responding to events for a single window. It’s all up to your own preferences and coding style.
Additional Events
~~~~~~~~~~~~~~
Your application will now respond to doListBox events. When the user clicks in a list box, Tools Plus generates a doListBox event. Your application can either respond to the event and do something right away (like in this tutorial), or do nothing until a Done or Cancel button is clicked (as you would see in many dialogs).
Some Cheating
~~~~~~~~~~~
To minimize this tutorial, we removed the pull-down menus (and made sure that they were not needed by using a modal window). We also reduced the event loop to account for only the doButton and doListBox events because we don’t need anything else.
List Manager Limits
~~~~~~~~~~~~~~~~
Tools Plus inherits the toolbox List Manager’s limitations in two areas:
• a list can contain a maximum of 32000 empty lines
• a list can contain no more than 32K of data
These limits were imposed in the early days of Macintosh when a really big computer had 640K of RAM, so 32K for a single list seemed ample at the time.
Realize that these limits are built right into Macintosh’s toolbox, and they are not limits imposed by Tools Plus alone.
If you need to break the 32K data limit, you have several options at your disposal:
(1) Write your own list management routines (and take care of
displaying, scrolling, and selecting)
(2) Get a third-party list manager, such as StoneTablet
Publishing’s “StoneTable” (Internet: stack@teleport.com or
phone: (503) 287-3424). It takes more work than Tools Plus
to get it working, but it breaks the 32K data barrier.
(3) Wait for a future release of Tools Plus in which we will